package com.cx.controller.lcd;

import com.cx.constant.ConstantData;
import com.cx.pojo.Gamelibrary;
import com.cx.pojo.User;
import com.cx.service.lcd.MoneydetailsService;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("moneydetails")
public class MoneydetailsController {

    @Autowired
    MoneydetailsService moneydetailsService;

    @RequestMapping("moneylist")
    @ResponseBody
    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd",timezone="GMT+8")
    public List<Gamelibrary> selectAll(HttpSession session) {
        User user = (User) session.getAttribute(ConstantData.SESSION_KEY);
        int userId = user.getUserId();
        List<Gamelibrary> gameLibraries= moneydetailsService.selectByUserId(userId);
        return gameLibraries;
    }
}